<?php

namespace frontend\modules\tsline\controllers;

use Yii;
use frontend\components\Controller;
use common\logics\TslineArticleLogic;
use frontend\modules\h5\models\RecentArticleSearch;

/**
 * 文章相关接口
 * ArticleController controller for the `tsline` module
 */
class ArticleController extends Controller {

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function verbs() {
        return [
            '*' => ['GET']
        ];
    }

    public $modelClass = 'frontend\modules\tsline\models\ArticleSearch';

    /**
     * @inheritdoc
     */
    public function actionIndex() {
        /* @var $modelClass \api\modules\tsline\models\ArticleSearch */
        $modelClass = new $this->modelClass;
        return $modelClass->search();
    }

    /**
     * @inheritdoc
     */
    public function actionRecent($time) {
        /* @var $modelClass \api\modules\tsline\models\ArticleSearch */
        $model = new RecentArticleSearch($time);
        return $model->search();
    }

    /**
     * 文章详情
     * @return array
     */
    public function actionView($id) {
        return TslineArticleLogic::findOne($id);
    }

}
